<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>卓捷留言系统</title>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/login/font.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/login/login.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/login/xadmin.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/layui/layui.js"
	charset="utf-8"></script>
<!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
<style type="text/css">
.login-bg {
	background: url(${pageContext.request.contextPath}/images/bg.png)
		no-repeat center;
	background-size: cover;
	overflow: hidden;
}

.login #darkbannerwrap {
	background: url(${pageContext.request.contextPath}/images/aiwrap.png);
	width: 18px;
	height: 10px;
	margin: 0 0 20px -58px;
	position: relative;
}
</style>
</head>
<body class="login-bg">
	<div class="login layui-anim layui-anim-up">
		<div class="message">卓捷留言系统登录</div>
		<div id="darkbannerwrap"></div>
		<form method="post" class="layui-form">
			<input name="userName" id="login" placeholder="用户名" type="text"
				class="layui-input">
			<hr class="hr15">
			<input name="password" id="password" placeholder="密码" type="password"
				class="layui-input">
			<hr class="hr15">
			<input value="登录" lay-submit lay-filter="login"
				onclick="requestJson()" style="width: 100%;" type="submit">
			<hr class="hr20">
			<span>还没有账号？去<a href="${pageContext.request.contextPath }/User/toregister">注册</a></span>
		</form>

	</div>

	<script type="text/javascript">
		function requestJson() {
			var name = $("#login").val();//#是id选择器
			var pwd = $("#password").val();
			if (name == "") {
				layer.msg("用户名不能为空！");
				return false;
			} else if (pwd == "") {
				layer.msg("密码不能为空！");
				return false;
			} else {
				$
						.ajax({
							type : 'post',
							url : '${pageContext.request.contextPath}/User/login',
							dataType : "json",
							async : true,
							data : {
								userName : name,
								password : pwd
							},
							success : function(data) {
								if (data == 0) {
									layer.msg("用户名或密码错误！")
								} else if (data == 1) {
									window.location.href = "${pageContext.request.contextPath}/Message/allMess";
								} else {
									window.location.href = "${pageContext.request.contextPath}/User/tologin";
								}
							}
						});
			}
		}
	</script>
	<script>
		$(function() {
			layui.use('form', function() {
				var form = layui.form;
				//监听提交
				form.on('submit(login)', function(data) {
					return false;
				});
			});
		})
	</script>
</body>
</html>